package com.changli05.exer.exer4;

import java.util.Scanner;

public class DivisionDemo {
    public static void main(String[] args) {
        try {
            int ia = Integer.parseInt(args[0]);
            int ib = Integer.parseInt(args[1]);
            int result = division(ia,ib);
            System.out.println(result);
        }catch(NumberFormatException e){
            System.out.println("数据类型不一致");
        }catch(ArithmeticException e){
            System.out.println("除以0了");
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("缺少命令行参数");
        }catch (BelowZeroException e){
            System.out.println("有负数");
        }
    }
    public static int division(int a, int b)throws BelowZeroException {
        if(a<0||b<0){
            throw new BelowZeroException("输入的数为负数");
        }
        return a/b;
    }
}
